From 42cab285b182495b558c0b4244d0728550ed9413 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Fri, 23 Feb 2024 10:22:21 -0600 Subject: [PATCH] Upgrade from psycopg2 to psycopg3; drop python <= v3.5, add v3.8-v3.11 --- setup.py | 6 ++++-- src/pgwui_bulk_upload/exceptions.py | 5 +++-- src/pgwui_bulk_upload/views/bulk_upload.py | 10 +++++----- tox.ini | 8 +++++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/setup.py b/setup.py index a543cd2..bff940f 100644 --- a/setup.py +++ b/setup.py @@ -116,10 +116,12 @@ setup( # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ], # What does your project relate to? diff --git a/src/pgwui_bulk_upload/exceptions.py b/src/pgwui_bulk_upload/exceptions.py index c34e24d..e19cf47 100644 --- a/src/pgwui_bulk_upload/exceptions.py +++ b/src/pgwui_bulk_upload/exceptions.py @@ -1,4 +1,5 @@ -# Copyright (C) 2020, 2021 The Meme Factory, Inc. http://www.karlpinc.com/ +# Copyright (C) 2020, 2021, 2024 The Meme Factory, Inc. +# http://www.karlpinc.com/ # This file is part of PGWUI_Bulk_Upload. # @@ -100,7 +101,7 @@ class CannotRollbackError(SetupError): 'The transaction has failed and must roll back before ' 'the database can again be queried about relations and ' 'their columns', - f'The error from psycopg2 is: ({exp})') + f'The error from psycopg3 is: ({exp})') class BadMapFileError(SetupError): diff --git a/src/pgwui_bulk_upload/views/bulk_upload.py b/src/pgwui_bulk_upload/views/bulk_upload.py index 02d3abc..ea7fdf3 100644 --- a/src/pgwui_bulk_upload/views/bulk_upload.py +++ b/src/pgwui_bulk_upload/views/bulk_upload.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015, 2018, 2020, 2021 The Meme Factory, Inc. +# Copyright (C) 2015, 2018, 2020, 2021, 2024 The Meme Factory, Inc. # http://www.karlpinc.com/ # This file is part of PGWUI_Bulk_Upload. @@ -25,7 +25,7 @@ import logging import os import os.path import pathlib -import psycopg2 +import psycopg import tempfile import zipfile @@ -98,7 +98,7 @@ class SaveBulkLine(DataLineProcessor, ParameterExecutor): ue UploadEngine instance uh UploadHandler instance insert_map Dict mapping file to insert statement used to insert - into db. (psycopg2 formatted for substituion) + into db. (psycopg3 formatted for substituion) ''' super().__init__(ue, uh) self.insert_map = insert_map @@ -127,7 +127,7 @@ class SaveBulkLine(DataLineProcessor, ParameterExecutor): error.color(map_description(filepath, relation), filepath, relation) raise exp - except psycopg2.DatabaseError as exp: + except psycopg.DatabaseError as exp: relation = data.relation raise core_ex.DBDataLineError(udl, exp).color( map_description(filepath, relation), @@ -605,7 +605,7 @@ class BulkTableUploadHandler(BaseTableUploadHandler): # new transaction. try: self.cur.execute('ROLLBACK;') - except psycopg2.DatabaseError as exp: + except psycopg.DatabaseError as exp: err = ex.CannotRollbackError(exp).color( map_description(fileinfo.filepath, fileinfo.relation), diff --git a/tox.ini b/tox.ini index 3eae53d..deebab3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,14 @@ [tox] -envlist = py{34,35,36,37} +envlist = py{36,37,38,39,310,311} [testenv] basepython = - py34: python3.4 - py35: python3.5 py36: python3.6 py37: python3.7 + py38: python3.8 + py39: python3.9 + py310: python3.10 + py311: python3.11 deps = check-manifest cmarkgfm -- 2.34.1